 package vista;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Vector;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextPane;
import javax.swing.WindowConstants;

import controlador.Utils;

/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class Bienvenida extends javax.swing.JFrame {
	private static final long serialVersionUID = 1L;
	private JLabel jLabel1;
	private JPanel encabezado;
	private JTextPane errorPerfil;
	private JButton proyButton;
	private JButton rolButton;
	private JButton estButton;
	private JButton jerButton;
	private JButton repoAdmButton;
	private JButton repoResButton;
	private JButton exitButton;
	private JButton busRecurButton;
	private JButton cosButton;
	private JButton horButton;
	private JButton tareaButton;
	private JButton userButton;
	private static Bienvenida instancia;
	private Vector<Integer> admitidos;


	private Bienvenida() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			admitidos = new Vector<Integer>();
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(null);
			getContentPane().setBackground(new java.awt.Color(255,255,255));
			this.setTitle("Bienvenido al Sistema TrackBase");
			{
				jLabel1 = new JLabel();
				getContentPane().add(jLabel1);
				String text = Utils.getUsuario();
				jLabel1.setText("Bienvenido/a " + text);
			}
			{
				proyButton = new JButton();
				getContentPane().add(proyButton);
				proyButton.setText("Proyectos");
				proyButton.setBounds(34, 124, 126, 23);
			}
			{
				userButton = new JButton();
				getContentPane().add(userButton);
				userButton.setText("Usuarios");
				userButton.setBounds(34, 158, 126, 23);
			}
			{
				tareaButton = new JButton();
				getContentPane().add(tareaButton);
				tareaButton.setText("Tareas");
				tareaButton.setBounds(177, 124, 126, 23);
			}
			{
				horButton = new JButton();
				getContentPane().add(horButton);
				horButton.setText("Horas");
				horButton.setBounds(177, 158, 126, 23);
			}
			{
				cosButton = new JButton();
				getContentPane().add(cosButton);
				cosButton.setText("Costos");
				cosButton.setBounds(177, 192, 126, 23);
			}
			{
				busRecurButton = new JButton();
				getContentPane().add(busRecurButton);
				busRecurButton.setText("Buscar Recursos");
				busRecurButton.setBounds(34, 260, 269, 23);
			}
			{
				exitButton = new JButton();
				getContentPane().add(exitButton);
				exitButton.setText("Salir");
				exitButton.setBounds(114, 363, 126, 23);
				
			}
			{
				repoResButton = new JButton();
				getContentPane().add(repoResButton);
				repoResButton.setText("Reportes de Resutado");
				repoResButton.setBounds(34, 294, 269, 23);
			}
			{
				repoAdmButton = new JButton();
				getContentPane().add(repoAdmButton);
				repoAdmButton.setText("Reporte de  Administracion");
				repoAdmButton.setBounds(34, 328, 269, 24);
			}
			{
				jerButton = new JButton();
				getContentPane().add(jerButton);
				jerButton.setText("Jerarquias");
				jerButton.setBounds(177, 226, 126, 23);
			}
			{
				estButton = new JButton();
				getContentPane().add(estButton);
				estButton.setText("Estados");
				estButton.setBounds(34, 226, 126, 23);
			}
			{
				rolButton = new JButton();
				getContentPane().add(rolButton);
				rolButton.setText("Roles");
				rolButton.setBounds(34, 192, 126, 23);
			}
			{
				errorPerfil = new JTextPane();
				errorPerfil.setBounds(34, 397, 269, 41);
				getContentPane().add(errorPerfil);
				getContentPane().add(getJPanel1());
			}
			exitButton.setBackground(new java.awt.Color(255,255,255));
			exitButton.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent evt) {
					System.out.println("jButton7.actionPerformed, event="+evt);
					dispose();
				}
			});
			proyButton.setBackground(new java.awt.Color(255,255,255));
			proyButton.setEnabled(false);
			userButton.setBackground(new java.awt.Color(255,255,255));
			userButton.setEnabled(false);
			tareaButton.setBackground(new java.awt.Color(255,255,255));
			tareaButton.setEnabled(false);
			horButton.setBackground(new java.awt.Color(255,255,255));
			horButton.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent evt) {
					System.out.println("jButton4.actionPerformed, event="+evt);
					HsUsuarios hsU = HsUsuarios.getinstancia();
					hsU.setLocationRelativeTo(null);
					hsU.setVisible(true);
					dispose();
				}
			});
			cosButton.setBackground(new java.awt.Color(255,255,255));
			cosButton.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent evt) {
					admitidos.clear();
					admitidos.add(1);
					admitidos.add(3);
					if(Utils.getInstancia().validar(admitidos)){
						System.out.println("jButton5.actionPerformed, event="+evt);
						AMCosto cos = AMCosto.getInstancia();
						cos.setLocationRelativeTo(null);
						cos.setVisible(true);
						dispose();
					}else{
						errorPerfil.setText("No posee los permisos requeridos para acceder a la funcionalidad");
					}
				}
			});
			busRecurButton.setBackground(new java.awt.Color(255,255,255));
			busRecurButton.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent evt) {
					admitidos.clear();
					admitidos.add(1);
					admitidos.add(3);
					if(Utils.getInstancia().validar(admitidos)){
						admitidos.add(1);
						admitidos.add(3);
						if(Utils.getInstancia().validar(admitidos)){
							System.out.println("jButton6.actionPerformed, event="+evt);
							BusquedaEmpleados be = BusquedaEmpleados.getInstancia();
							be.setLocationRelativeTo(null);
							be.setVisible(true);
							dispose();
						}else{
							errorPerfil.setText("No posee los permisos requeridos para acceder a la funcionalidad");
						}
					}
			}
			});
			repoResButton.setBackground(new java.awt.Color(255,255,255));
			repoResButton.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent evt) {
					admitidos.clear();
					admitidos.add(1);
					admitidos.add(3);
					if(Utils.getInstancia().validar(admitidos)){
						System.out.println("jButton8.actionPerformed, event="+evt);
						ReporteResultado r = ReporteResultado.getInstancia();
						r.setLocationRelativeTo(null);
						r.setVisible(true);
						dispose();
					}else{
						errorPerfil.setText("No posee los permisos requeridos para acceder a la funcionalidad");
					}
				}
			});

			repoAdmButton.setBackground(new java.awt.Color(255,255,255));
			repoAdmButton.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent evt) {
					admitidos.clear();
					admitidos.add(1);
					admitidos.add(3);
					if(Utils.getInstancia().validar(admitidos)){
						System.out.println("jButton9.actionPerformed, event="+evt);
						ResultadoAdministracion r = ResultadoAdministracion.getInstancia();
						r.setLocationRelativeTo(null);
						r.setVisible(true);
						dispose();
					}else{
						errorPerfil.setText("No posee los permisos requeridos para acceder a la funcionalidad");
					}
				}
			});
			
			jerButton.setBackground(new java.awt.Color(255,255,255));
			jerButton.setEnabled(false);
			estButton.setBackground(new java.awt.Color(255,255,255));
			estButton.setEnabled(false);
			rolButton.setBackground(new java.awt.Color(255,255,255));
			rolButton.setEnabled(false);

			pack();
			this.setSize(350, 488);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static Bienvenida getinstancia() {
		if(instancia == null)
			return new Bienvenida();
		return instancia;
	}

	public void setUser(String text) {
		
	}	
	
	private JPanel getJPanel1() {
		if(encabezado == null) {
			encabezado = new Logo(true);
			encabezado.setBounds(46, 28, 244, 71);
		}
		return encabezado;
	}

	/*private JLabel getErrorPerfil() {
		if(errorPerfil == null) {
			errorPerfil = new JLabel();
			errorPerfil.setBounds(34, 397, 269, 41);
		}
		return errorPerfil;
	}*/

}
